package face.jvm;

/**
 * Created by zhangyanfei on 2019/6/26.
 * 线程操作资源类
 *
 * @author zhangyanfei
 * @date 2019/06/26
 */
public class SynchronizedDemo {

    public static synchronized void print() {
        System.out.println("demo");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Thread(() -> {
            SynchronizedDemo.print();
        }).start();

        new Thread(() -> {
            SynchronizedDemo.print();
        }).start();

    }
}
